home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / AEGestalt 1.0 / UAEClientCommand.cp < prev    next >
Encoding:
Text File  |  1992-07-15  |  2.3 KB  |  86 lines  |  [TEXT/MPS ]

  1. //    UAEClientCommand.cp
  2. //     Copyright © 1991-92 by Apple Computer, Inc. All rights reserved.
  3. //    Kent Sandvik DTS
  4. //    This file contains all the TAEClientCommand member functions, i.e.
  5. //    for creating an Apple event which will query a server over the network.
  6. //
  7. //    <1>        khs        1.0        First final version
  8.  
  9.  
  10. #ifndef __AECLIENTCOMMAND__
  11. #include "UAEClientCommand.h"
  12. #endif
  13.  
  14.  
  15. //    Empty constructor - for avoiding ptabs in global data space
  16. #pragma segment ARes
  17. TAEClientCommand::TAEClientCommand()
  18. {
  19. }
  20.  
  21.  
  22. //     Put together the client AppleEvent, which will call the server asking for
  23. //    Gestalt information
  24. #pragma segment ASelCommand
  25. pascal void TAEClientCommand::IAEClientCommand(CommandNumber theNum,
  26.                                                TAEDocument* theDocument,
  27.                                                AEEventID theID)
  28. {
  29.     AEAddressDesc theAddress;
  30.     FailInfo fi;
  31.  
  32.     // save document wherefrom command is issued
  33.     fDocument = theDocument;
  34.  
  35.     this->IClientCommand(theNum, theDocument, kCantUndo, kDoesNotCauseChange, NULL);
  36.  
  37.     if (fi.Try())
  38.     {
  39.         // setup fMessage to contain the data for our Gestalt GetData AppleEvent
  40.         theDocument->GetAEGestaltAddress(theAddress);
  41.  
  42.         TAppleEvent * aMessage = new TAppleEvent;// create AE object
  43.         aMessage->IAppleEvent(kMacAppClass, theID, theAddress, kAEQueueReply);
  44.         fMessage = aMessage;
  45.  
  46.         fi.Success();
  47.     }
  48.     else
  49.     {
  50.         this->Free();
  51.         fi.ReSignal();
  52.     }
  53. }
  54.  
  55.  
  56. //    Process replies that gets back to the client side from the AE server
  57. #pragma segment ADoCommand
  58. pascal void TAEClientCommand::ProcessReply(TAppleEvent* theReply)
  59. {
  60.     CStr255 theResponse;
  61.     long actualSize;
  62.     DescType actualCode;
  63.     struct Configuration tempConfig;
  64.  
  65.     // handle inherited processing and check for AE errors    
  66.     inherited::ProcessReply(theReply);
  67.     FailOSErr(theReply->ReadShort('errn'));
  68.  
  69.     // if OK, continue processing the reply - store it in the document
  70.     theReply->ReadParameterPtr(kAEConfig, typeConfig, actualCode, (Ptr) & tempConfig, sizeof(Configuration), actualSize);
  71.  
  72.     // Now move the tempConfig to the fDocument itself.
  73.     fDocument->ReadConfiguration(&tempConfig);
  74.  
  75.     // FUTURE: Make a TProcessGestaltCommand which will process the information
  76.     // and store it in the TInformationView
  77.     // TProcessGestaltCommand aCommand = new TProcessGestaltCommand(this,tempConfig);
  78.     // and so on...
  79.  
  80.     // Process the reply to a more suitable format, this is done from the
  81.     // document itself for the view class
  82.     fDocument->ProcessAEInformation();
  83. }
  84.  
  85.  
  86.